﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using STKMIS.DAL;

namespace STKMIS.BLL
{
    /// <summary>
    /// 公用类
    /// </summary>
    public class Common
    {
        /// <summary>
        /// 获取序号
        /// </summary>
        /// <param name="BillType">--单据类型(采购：CG，入库：RK，销售：XS，出库：CK，物流：WL)</param>
        /// <param name="IsNeedDate">是否随日期增长，0：否，1：是</param>
        /// <returns></returns>
        public static string GetSerialNumber(string BillType, int IsNeedDate, ref string msg)
        {
            try
            {

                List<SqlDBParameter> param = new List<SqlDBParameter>();

                param.Add(new SqlDBParameter("@BillType", DbType.String, BillType));
                param.Add(new SqlDBParameter("@IsNeedDate", DbType.Int32, IsNeedDate));

                param.Add(new SqlDBParameter("@SerialNumber", DbType.String, ParameterDirection.Output, 13));

                //tran.Transaction
                int executedRows = SqlDBServer.ExecuteStoredProc("proc_GetSerialNumber", param, null, SqlDBServer.SqlConnStringModelDb);
                if (param[2].Value != null)
                {
                    msg = "获取成功";
                    return param[2].Value.ToString();
                }
            }
            catch
            {
                msg = "获取失败";
                return "";
            }
            return "";
        }
    }
}
